define([ 'require', 'angularAMD', 'Stream', 'SparkMD5', 'text!root/file/getServer' ], function(require, angularAMD, Stream, SparkMD5,
		server) {
	server = (server.charAt(server.length - 1) == '/') ? server.substring(0, server.length - 1) : server
	function UploadService($http) {
		var ctrl = this
		this.create = function(config) {
			var cfg = {
				multipleFiles : true,
				maxSize : 104857600,
				tokenURL : server + "/tk",
				uploadURL : "upload",
				swfURL : server + "/asset/swf/FlashUploader.swf",
				frmUploadURL : "/fd",
				autoUploading : false,
				customered : true
			}
			angular.extend(cfg, config)
			return new Stream(cfg);
		}
		this.getServerUrl = function() {
			return server;
		}
		this.findFile = function(hash, size, files) {
			for ( var i in files) {
				var f = files[i]
				if (f.hash == hash && f.size == size) {
					return f;
				}
			}
		}
		return this;
	}
	angularAMD.factory('UploadService', UploadService)
})